#include "Spark/Utils/AsyncFileLogger.h"
#include "Spark/Utils/Logger.h"

using namespace wb;

int main()
{
    AsyncFileLogger asyncFileLogger;
    asyncFileLogger.setFileName(FileName().setBaseName("async_test").setPath("./"));
    asyncFileLogger.startLogging();
    Logger::setOutputFunction(
        [&](const char *msg, const uint64_t len) {
            asyncFileLogger.output(msg, len);
        },
        [&]() { asyncFileLogger.flush(); });
    asyncFileLogger.setFileSizeLimit(100000000);

    int i = 0;
    while (i < 1000000)
    {
        ++i;
        if (i % 100 == 0)
        {
            LOG_ERROR << "this is the " << i << "th log";
            continue;
        }
        LOG_INFO << "this is the " << i << "th log";
        ++i;
        LOG_DEBUG << "this is the " << i << "th log";
    }
}
